package com.scr.apigateway;

import com.scr.springbootinit.provider.DemoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Service;

@SpringBootApplication
@EnableDubbo
@Service
public class ApiGatewayApplication {

    @DubboReference
    private DemoService demoService;

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(ApiGatewayApplication.class, args);
        ApiGatewayApplication apiGatewayApplication = context.getBean(ApiGatewayApplication.class);
        String world = apiGatewayApplication.doSayHello("world");
        String xiaoshen = apiGatewayApplication.doSayHi("xiaoshen");
        System.out.println(world);
        System.out.println(xiaoshen);
    }

    public String doSayHello(String name){
        return demoService.sayHello(name);
    }

    public String doSayHi(String name){
        return demoService.sayHi(name);
    }

}
